#include <iostream>
using namespace std;
int main()
{
	int n,a;
	int i,limit,total=0,g;
	cin>>limit>>n;
	for (i=1;i<=limit;i++)
	{
		a = i;
		if (i<10 && i==n) total = total + 1;
		else if (i>=10)
		{
			while(a!=0)
			{
				g = a % 10;
				a = a / 10;
				if (g==n) total = total + 1; 
			}
		 } 
	}
	cout<<total<<endl;
	return 0;
}
